.TH std::experimental::rebind_simd,std::experimental::resize_simd 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::experimental::rebind_simd,std::experimental::resize_simd \- std::experimental::rebind_simd,std::experimental::resize_simd

.SH Synopsis
   Defined in header <experimental/simd>
   template< class T, class V >          \fB(1)\fP (parallelism TS v2)
   struct rebind_simd;
   template< int N, class V >            \fB(2)\fP (parallelism TS v2)
   struct resize_simd;

   Creates a simd or simd_mask type with a different element type or size. The new type
   likely uses an ABI tag type different from V::abi_type.

   1) Changes the element type to T and keeps the size unchanged.
   2) Changes the size to N and keeps the element type unchanged.

.SH Template parameters

   T - the new element type; an arithmetic type other than bool
   N - the new number of elements
   V - a simd or simd_mask type

.SH Member types

   Name Definition
   type simd or simd_mask type with a different element type \fB(1)\fP or size \fB(2)\fP

.SH Helper types

   template< class T, class V >                             (parallelism TS v2)
   using rebind_simd_t = typename rebind_simd<T, V>::type;
   template< int N, class V >                               (parallelism TS v2)
   using resize_simd_t = typename resize_simd<N, V>::type;

.SH Example


// Run this code

 #include <experimental/simd>
 #include <iostream>

 namespace stdx = std::experimental;
 using floatv = stdx::native_simd<float>;

 // use double precision internally
 floatv dp(floatv x)
 {
     using doublev = stdx::rebind_simd_t<double, floatv>;
     return stdx::static_simd_cast<floatv>(stdx::simd_cast<doublev>(x) - 1.234);
 }

 template<class T>
 stdx::resize_simd_t<T::size() / 2, T> partial_reduction(T x)
 {
     auto [lo, hi] = stdx::split<stdx::resize_simd_t<T::size() / 2, T>>(x);
     return lo + hi;
 }

 int main()
 {
     floatv x([](auto i) { return 1.234f + std::numeric_limits<float>::epsilon() * i; });
     x = dp(x);
     const auto y = partial_reduction(x);
     for (unsigned i = 0; i < y.size(); ++i)
         std::cout << y[i] << ' ';
     std::cout << '\\n';
 }

.SH Possible output:

 1.73569e-07 4.11987e-07

.SH See also

   deduce              obtains an ABI type for given element type and number of
   deduce_t            elements
   (parallelism TS v2) \fI(class template)\fP
